package com.newtouch.avmarketing.mgr.modules.avmarkrting.repo;

import com.newtouch.avmarketing.mgr.modules.avmarkrting.entity.ConfigurationContent;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

@Repository
public interface ConfigurationContentRepo extends JpaRepository<ConfigurationContent,Long>
        , PagingAndSortingRepository <ConfigurationContent,Long>{

    List<ConfigurationContent> findByStepId(Long stepId);

    @Modifying
    @Transactional
    @Query(value = "update configuration_content set is_deleted ='1' " +
            "where is_deleted = '0' and step_id = ?1",nativeQuery = true)
    int deleteConfigurationContentByStepId(Long stepId);
}
